﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using System.Linq;

namespace Feniks
{
    public partial class frmMasuraGramaj : DevExpress.XtraEditors.XtraForm
    {
        private List<Gramaj> _gramaj = new List<Gramaj>();
        public List<Gramaj> Gramajlar { get { return _gramaj; } }
        public int MasuraID { get; set; }

        public frmMasuraGramaj()
        {
            InitializeComponent();
        }

        private void frmMasuraGramaj_Load(object sender, EventArgs e)
        {
            if (MasuraID > -1)
            {
                using (DataEntities ent = new DataEntities())
                {
                    var liste = ent.MasuraOlculeri.Where(x => x.MasuraID == MasuraID).ToList();
                    foreach (var item in liste)
                    {
                        _gramaj.Add(new Gramaj()
                        {
                            Gram = item.Gram,
                            Olcu = item.Metre.ToString()
                        });
                    }
                }
            }

            for (int i = 0; i < 30 - _gramaj.Count; i++)
            {
                _gramaj.Add(new Gramaj());
            }
            gridControl1.DataSource = _gramaj;
        }

        private void simpleButton1_Click(object sender, EventArgs e)
        {
            this.DialogResult = System.Windows.Forms.DialogResult.OK;
        }
    }
}